import { Injectable } from '@angular/core';
import { ConfigService } from './config.service';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Carousel } from '../model/carousel';

@Injectable()
export class CarouselService {

  constructor(
    private http:HttpClient,
    private config:ConfigService
  ) { }

  private addCarouselUrl=this.config.host+"/manage/addCarousel";
  addCarousel(carousel:Carousel){
    return this.http.post(this.addCarouselUrl,carousel).toPromise();
  }

  private updateCarouselsUrl=this.config.host+"/manage/updateCarousel";
  updateCarousel(carousel:Carousel){
    return this.http.post(this.updateCarouselsUrl,carousel).toPromise();

  }

  private getCarouselListUrl=this.config.host+"/manage/getCarouselList";
  getCarouselList(){
    
    return this.http.get(this.getCarouselListUrl).toPromise();
  }

  private getCarouselUrl=this.config.host+"/manage/getCarousel";
  getCarousel(id:string){
    let p={
      "carouselid":id
    }
    return this.http.post(this.getCarouselUrl,p).toPromise();
  }

  private deleteCarouselUrl=this.config.host+"/manage/deleteCarousel";
  deleteCarousel(id:string){
      let p={
        "carouselid":id
      }
      return this.http.post(this.deleteCarouselUrl,p).toPromise();
    }

   
}
